<?php

namespace app\admin\model;

/**
 *  客户跟进记录表
*/
class FollowRecords extends BaseModel
{
    protected $attributes = [
        'follow_method' => [
            1 => '当面拜访',
            2 => '电话拜访',
            3 => '网络拜访',
            4 => 'KOL/网站内容发布'
        ],
        'follow_business' => [
            1 => '合同订单'
        ],
        'order_type' => [
            'wholesal' => '经销商订单',
            'order' => '普通订单'
        ]
    ];


    /**
     *  获取字段枚举
    */
    protected $enumCallbacks = [
        'operator' => 'getOperatorEnum'
    ];

    /**
     *  获取字段枚举
     */
    public function getFieldEnum($field)
    {
        return $this->getEnum($field,[],'label');
    }

    /**
     *  获取创始人
     */
    public function getOperatorEnum(){
        return Operator::order('cname ASC')
            ->column('id as value,cname as label');
    }



    /**
     *  管理员
    */
    public function creatorName()
    {
        return $this->hasOne(Operator::class, 'id', 'creator');
    }


    /**
     *  客户名字
     */
    public function customerName()
    {
        return $this->hasOne(Customer::class, 'id', 'customer_id');
    }



}
